
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<title>签约申请</title>
	<meta http-equiv="Content-type" content="textml; charset=utf-8" />
	<meta content="telephone=no" name="format-detection" />
	<meta name="x5-orientation" content="portrait">
	<meta name="screen-orientation" content="portrait">
	<meta name="viewport"
		content="width=device-width,height=device-height,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=yes">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="icon" href="data:;base64,=">
	<link rel="stylesheet" type="text/css" href="//img.ejiayou.com/activity/pages/ejiayoupay/ejiayou/css/reset.css" />
	<link rel="stylesheet" href="css/index.css" />
	<link rel="stylesheet" type="text/css" href="css/index_style.css" />

	<style type="text/css">
		.location_show {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			z-index: 10;
			background: #F7F8FA;
		}

		#container {
			width: 100%;
			height: 13.44rem;
			overflow: hidden;
			position: relative;
		}

		#result {
			position: fixed;
			top: 10px;
			left: 10px;
			width: 250px;
			height: 30px;
			line-height: 30px;
			text-align: center;
			background: #fff;
			box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
			border-radius: 7px;
			z-index: 99;
		}

		#remark {
			width: 0.81rem;
			height: 1.13rem;
			position: absolute;
			display: flex;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			z-index: 1000;
		}

		#remark img {
			width: 100%;
			height: 100%;
		}

		.container_xx {
			position: relative;
			width: 100%;
			height: 13.44rem;
		}

		.submit_box {
			margin: 0 auto;
			margin-top: 0.63rem;
			width: 10.78rem;
			height: 1.56rem;
			background: linear-gradient(318deg, #FF9100 0%, #FFA400 100%);
			border-radius: 0.19rem;
			display: flex;
			font-size: 0.56rem;
		}

		.submit_box .van-button {
			width: 10.78rem;
			height: 1.56rem;
			background: linear-gradient(318deg, #FF9100 0%, #FFA400 100%);
			border-radius: 0.19rem;
			color: #fff;
			border: none;
			font-size: 0.56rem;
		}

		.van-popup {
			background: #F5F5F5;
		}

		.search_info {
			width: 100%;
			background: #FFFFFF;
		}

		.search_item {
			width: 96%;
			height: 1.25rem;
			border-bottom: 0.02rem solid #D8D8D8;
			font-size: 0.44rem;
			font-weight: 400;
			color: #333333;
			line-height: 1.25rem;
			margin-left: 4%;
		}

		.search1 {
			background: #F5F5F5;
		}

		.search1 .van-search__content {
			background: #FFFFFF;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="load_end" v-if="!loadEnd"></div>
		<div class="step_box">
			<img src="https://img.ejiayou.com/activity/jiguang_upload/img/step_active_one.png">
		</div>
		<div class="" style="width: 100%;">
			<!--				<div class="tab_content" v-if="work_order_id &&!replace">-->
			<!--					<div class="tab_item tab_active">-->
			<!--						<span>审核信息</span>-->
			<!--					</div>-->
			<!--					<div class="tab_item" @click="comeToExtraMsg">-->
			<!--						<span>补充信息</span>-->
			<!--					</div>-->
			<!--				</div>-->
			<div class="main_active">
				<van-form @submit="onSubmit">
					<van-cell value="油站基础信息"></van-cell>
					<van-field @click="showStation" readonly clickable v-model="stationName"
						:readonly="look_gd || stationNameReadonly ? true:false" name="油站名称" label="油站名称"
						placeholder="油站名称" :rules="[{ required: true, message: '*请填写油站名称' }]"></van-field>
					<van-field readonly clickable name="area" :value="station_area" label="地址选择" placeholder="点击选择省市区"
						@click="showArea" right-icon="arrow"></van-field>
					<van-popup v-model="show_area" position="bottom">
						<van-area :area-list="area_list" :value="area_value" @confirm="comfirmArea"
							@cancel="show_area = false"></van-area>
					</van-popup>
					<van-field v-model="stationAddress" name="详细地址" label="详细地址" placeholder="详细地址"
						:readonly="look_gd?true:false"></van-field>
					<van-field class="van_field_long_length" readonly clickable name="area" :value="longitude_latitude"
						label="请选择经纬度" @click="showLocationSelect" right-icon="arrow"
						:rules="[{ required: true, message: '*请选择经纬度' }]"></van-field>
					<div class="submit_box" @click="saveGongdan" v-if="!work_order_id || replace">
						<van-button round block type="info" native-type="button">添加新油站</van-button>
					</div>
					<div class="other_active" v-if="work_order_id && !replace">

						<van-field class="van_field_margin" name="radio" label="油站规模">
							<template #input>
								<van-radio-group v-model="scale" direction="horizontal" :disabled="look_gd?true:false">
									<van-radio name="1">
										单站
										<template #icon="props">
											<img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
										</template>
									</van-radio>
									<van-radio name="2">集团站
										<template #icon="props">
											<img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
										</template>
									</van-radio>
								</van-radio-group>
							</template>
						</van-field>
						<van-field v-model="organizationName" v-if="scale==2" name="集团名称" label="集团名称"
							placeholder="集团名称" :rules="[{ required: true, message: '*请填写集团名称' }]"
							:readonly="look_gd?true:false"></van-field>
						<van-field readonly clickable v-model="organization_name" name="油站类型" label="油站类型"
							placeholder="油站类型" right-icon="arrow" @click="showOrganizationPicker"
							:rules="[{ required: true, message: '*请选择油站类型' }]"></van-field>
						<van-popup v-model="show_organization_picker" position="bottom">
							<van-picker show-toolbar :columns="organizations" @confirm="organizationComfirm"
								@cancel="show_organization_picker = false"></van-picker>
						</van-popup>
						<van-field v-model="stationLevelName" name="油站P级" label="油站P级" placeholder="油站P级"
							@click="showLevelPicker" right-icon="arrow" readonly clickable
							:rules="[{ required: true, message: '*请选择油站P级' }]"></van-field>
						<van-popup v-model="show_level_picker" position="bottom">
							<van-picker show-toolbar :columns="stationLevelArr" @confirm="stationLevelComfirm"
								@cancel="show_level_picker = false"></van-picker>
						</van-popup>
						<van-cell value="油站人员信息"></van-cell>
						<van-field v-model="telephone" type="tel" name="柜台电话" label="柜台电话" placeholder="柜台电话"
							type="number" :rules="[{ required:true, message: '*请填写柜台电话' }]"
							:readonly="look_gd?true:false"></van-field>
						<van-field v-model="managerName" name="站长姓名" label="站长姓名" placeholder="站长姓名"
							:rules="[{ required: true, message: '*请填写站长姓名' }]" :readonly="look_gd?true:false">
						</van-field>
						<!--							<van-field :value="positionName" name="picker" label="职务名称" readonly clickable right-icon="arrow" @click="showPositionPicker"-->
						<!--							 :rules="[{ required: true, message: '*请选择职务名称' }]"></van-field>-->
						<van-popup v-model="show_position_picker" position="bottom">
							<van-picker show-toolbar :columns="positionArr" @confirm="stationPositionComfirm"
								@cancel="show_position_picker = false"></van-picker>
						</van-popup>
						<van-field v-model="email" type="email" name="站长邮箱" label="站长邮箱" placeholder="站长邮箱"
							:rules="[{ validator: validatorEmail, message: '*请填写正确的站长邮箱' }]"
							:readonly="look_gd?true:false"></van-field>
						<van-field v-model="phone" type="tel" name="站长电话" label="站长电话" placeholder="站长电话"
							:rules="[{ validator: validatorPhone, message: '*请填写正确的站长电话' }]"
							:readonly="look_gd?true:false"></van-field>
						<p class="tips">*该手机号将用于登录易加油H5，审批上线</p>
						<van-cell value="销售信息"></van-cell>
						<van-field name="radio" label="竞对信息">
							<template #input>
								<van-radio-group v-model="station_race_infomation" direction="horizontal"
									:disabled="look_gd?true:false">
									<van-radio name="0">
										无
										<template #icon="props">
											<img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
										</template>
									</van-radio>
									<van-radio name="1">有
										<template #icon="props">
											<img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
										</template>
									</van-radio>
								</van-radio-group>
							</template>
						</van-field>
						<div class="submit_box" v-if="!look_gd">
							<van-button round block type="info" native-type="submit">保存并下一步</van-button>
						</div>
						<div class="submit_box" v-if="look_gd" @click="lookNextStep">
							<van-button round block type="info" native-type="button">查看下一步</van-button>
						</div>
						<div class="submit_box" v-if="from_page">
							<van-button round block type="info" native-type="button" @click="resetPage">关闭</van-button>
						</div>
					</div>
				</van-form>
				<div class="mask_curr" v-if="showNotPosition">
					<div class="mask_box">
						<p class="mask_title">请开启手机定位，否则无法获取位置</p>
						<div class="submit_button" @click="rebackUrl">
							<span>我知道了</span>
						</div>
					</div>
				</div>
			</div>

		</div>
		<div v-show="showPopup" class="location_show">
			<van-search v-model="station_juti_address" show-action label="查找油站" placeholder="请输入具体地址">
				<template #action>
					<div @click="onSearch">搜索</div>
				</template>
			</van-search>

			<div class="container_xx">
				<div id='container'></div>
				<div id="remark">
					<img src="img/hj_map_btn_oil@2x.png">
				</div>
			</div>
			<div class="submit_box" @click="selectThisAddress">
				<van-button round block type="info" native-type="button">确认选择</van-button>
			</div>
		</div>
		<van-popup v-model="show" position="right" style="height:100%;width:100%" @click="show=false">
			<van-search class='search1' @click.stop v-model="stationValue" placeholder="请输入搜索关键词" input-align="left"
				@input="searchiInput"></van-search>
			<div class="search_info">
				<div class="search_item" v-for='(item,index) in stationList' @click="searchClick(item)">
					{{item.station_name}}</div>
			</div>
		</van-popup>
	</div>
	<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://img.ejiayou.com/activity/js/common/jquery.min.js" type="text/javascript"
		charset="utf-8"></script>
	<script type="text/javascript" id="baiduMapAddress"
		src="//api.map.baidu.com/api?v=1.0&type=webgl&ak=WZp3MbqSXW5YUgDSYIMaqLQHd0tKZeKq"></script>
	<script src="js/vant.min.js"></script>
	<script src="js/utils.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/area.js" type="text/javascript" charset="utf-8"></script>

	<script type="text/javascript">
		eval(function (p, a, c, k, e, r) {
			e = function (c) {
				return c.toString(a)
			};
			if (!''.replace(/^/, String)) {
				while (c--) r[e(c)] = k[c] || e(c);
				k = [function (e) {
					return r[e]
				}];
				e = function () {
					return '\\w+'
				};
				c = 1
			};
			while (c--)
				if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
			return p
		}('(6(a,d){j b=a.i,e="3"f 5?"3":"9",c=6(){b.7.8=(2>b.4?b.4:2)/2*g+"h"};a.0&&(d.0(e,c,!1),a.0("k",c,!1))})(l,5);',
			22, 22,
			'addEventListener||750|orientationchange|clientWidth|window|function|style|fontSize|resize||||||in|64|px|documentElement|var|DOMContentLoaded|document'
				.split('|'), 0, {}))
	</script>
	<script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script>
	<script>
		// var vConsole = new VConsole();
		//替换指定传入参数的值,paramName为参数,replaceWith为新值
		function replaceParamVal(href, paramName, replaceWith) {
			var oUrl = href.toString();
			var re = eval('/(' + paramName + '=)([^&]*)/gi');
			var nUrl = oUrl.replace(re, paramName + '=' + replaceWith);
			return nUrl
		}
		var json_list = ''
		if (localStorage.getItem('ejy_json_list')) {
			json_list = JSON.parse(localStorage.getItem('ejy_json_list'))
		}
		var admin_id = getQueryVariable('admin_id') || ''
		var from_page = getQueryVariable('from') || ''
		var work_order_id = getQueryVariable('work_order_id') || ''
		var order_type_id = getQueryVariable('order_type_id') || 1
		var replace = getQueryVariable('replace') || ''
		if (work_order_id) {

		} else {
			if (localStorage.getItem('ejy_work_order_id')) {
				work_order_id = localStorage.getItem('ejy_work_order_id')
			} else {

			}
		}
		var look_gd = getQueryVariable('look_gd') || ''
		var look_gd_text = getQueryVariable('look_gd_text') || ''


		var map
		var myGeo
		// 在 #app 标签下渲染一个按钮组件
		new Vue({
			el: '#app',
			data: {

				activeIcon: 'https://img.ejiayou.com/activity/jiguang_upload/img/active_icon.png',
				inactiveIcon: 'https://img.ejiayou.com/activity/jiguang_upload/img/inactive_icon.png',
				active: 0,
				showPopup: false,
				show_area: false,
				loadEnd: false,
				area_list: '',
				show_organization_picker: false, //显示油站类型picker
				station_area: '',
				cityName: '',
				stationName: "", //油站名称
				provinceId: '', //省市县，对应地址选择栏
				cityId: '',
				townsId: '',
				longitude_latitude: '',
				longitude: '',
				latitude: '',
				area_value: '',
				stationAddress: "", //详细地址
				organization: '', //油站类型
				scale: '1', //油站规模（1单站，2集团站）
				organizationName: "", //集团名称
				organization_name: '',
				stationLevelName: "", //油站P级
				stationLevel: '',
				telephone: "", //柜台电话
				managerName: "", //管理人姓名
				positionId: 1, //职务
				show_position_picker: false,
				positionName: '站长',
				classId: 1,
				replace: replace,
				positionArr: [ //职务
					{
						positionId: 1,
						text: "站长"
					},
					{
						positionId: 2,
						text: "集团负责人"
					},
					{
						positionId: 3,
						text: "油站老板"
					},
					{
						positionId: 4,
						text: "商务"
					}
				],
				email: '',
				phone: "", //管理人
				organizations: [],
				show_level_picker: false,
				stationLevelArr: [{
					stationLevel: 1,
					text: "p1级"
				},
				{
					stationLevel: 2,
					text: "p2级"
				},
				{
					stationLevel: 3,
					text: "p3级"
				},
				{
					stationLevel: 4,
					text: "p4级"
				},
				{
					stationLevel: 5,
					text: "p5级"
				},
				{
					stationLevel: 6,
					text: "p6级"
				},
				{
					stationLevel: 7,
					text: "p7级"
				},
				{
					stationLevel: 8,
					text: "p8级"
				},
				{
					stationLevel: 9,
					text: "p9级"
				},
				{
					stationLevel: 10,
					text: "p10级"
				}
				],
				station_race_infomation: "0",
				preferential_type: 1,
				prefer_refer_price: 1,
				prefer_refer_way: 1,
				cooperate_oil: [],
				station_printer: 1,
				counter_machine_number: '',
				smoke_servant_meals: [],
				oil_station_partner: 1,
				work_order_id: work_order_id,
				look_gd_text: look_gd_text,
				look_gd: look_gd,
				order_type_id: order_type_id,
				admin_id: admin_id,
				address_detail: '',
				showNotPosition: false,
				station_juti_address: '',
				from_page: from_page,
				stationNameReadonly: false,
				show: false,
				stationValue: '',
				stationList:[],
      			contractPicList:{},
      			work_order_id_sign:'',//油站选择的work_order_id
      			contractPics:[]
			},
			created() {
				var self = this
				this.area_list = area_list
				if(getQueryVariable('sign_id')){
					self.getFormData2()
				}
				if (getQueryVariable('station_name')) {
					this.stationNameReadonly = true
					this.stationName = decodeURIComponent(getQueryVariable('station_name'))
				} else {
					this.stationNameReadonly = false
				}
			},
			mounted() {
				localStorage.removeItem('ejy_cooperate_oil')
				localStorage.removeItem('ejy_oilInfo')
				var self = this
				this.getLocation(function () {
					if (self.work_order_id) {
						self.getFormData(function () {
							if (json_list) {

								self.stationName = json_list.stationName || '' //油站名称
								self.cityName = json_list.cityName || ''
								self.provinceId = json_list.provinceId //省市县，对应地址选择栏
								self.cityId = json_list.cityId
								self.townsId = json_list.townsId
								self.station_area = json_list.station_area
								self.stationAddress = json_list.stationAddress //详细地址
								if (json_list.longitude) {
									self.longitude_latitude = json_list.longitude + ',' + json_list.latitude
									self.longitude = json_list.longitude
									self.latitude = json_list.latitude
								}
								if (json_list.longitude_latitude) {
									self.longitude_latitude = json_list.longitude_latitude
									self.longitude = json_list.longitude
									self.latitude = json_list.latitude
								}

								self.area_value = json_list.area_value || ''
								self.longitude = json_list.longitude || ''
								self.latitude = json_list.latitude || ''

								self.organization = json_list.organization || '1' //油站类型
								self.scale = json_list.scale || "1" //油站规模（1单站，2集团站）
								self.organizationName = json_list.organizationName || '' //集团名称
								self.organization_name = json_list.organization_name || ''
								self.stationLevel = json_list.stationLevel || '' //油站P级
								self.telephone = json_list.telephone || '' //柜台电话
								self.managerName = json_list.managerName || '' //管理人姓名
								self.positionId = json_list.positionId || '' //职务
								self.positionName = json_list.positionName || ''
								self.email = json_list.email || ''
								self.station_race_infomation = json_list.station_race_infomation || '0'
								self.phone = json_list.phone || '' //管理人
							}
							self.getStationType(function () {
								if (json_list.organization) {
									self.organization_name = self.organizations.find(function (element) {
										return element.organizationId == json_list.organization
									}).text
								}
							})

							if (json_list.stationLevel) {
								self.stationLevelName = self.stationLevelArr.find(function (element) {
									return element.stationLevel == json_list.stationLevel
								}).text
							}
							if (json_list.positionId) {
								self.positionName = self.positionArr.find(function (element) {
									return element.positionId == json_list.positionId
								}).text
							}

						})

					}
					self.loadEnd = true

				})

			},
			methods: {
				resetPage: function () {
					history.back()
				},
				showLocationSelect: function () {
					if (look_gd) {
						return
					}
					this.showPopup = true
					this.station_juti_address = this.stationAddress
					this.initData()
					console.log('点击请选择经纬度')
				},
				validatorPhone: function (val) {
					return /(^0\d{2,3}-?\d{7,8}$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/.test(val)
				},
				validatorEmail: function (val) {
					return /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(val)
				},
				rebackUrl: function () {
					history.back()
				},
				initData: function () {
					map = new BMapGL.Map('container');
					map.centerAndZoom(new BMapGL.Point(116.331398, 39.897445), 12);
					//创建地址解析器实例
					myGeo = new BMapGL.Geocoder();
					map.enableScrollWheelZoom(true);

					console.log(this.cityName)
					console.log(this.station_juti_address)
					myGeo.getPoint(this.station_area + this.station_juti_address, function (point) {
						if (point) {
							map.centerAndZoom(point, 16);
						} else {
							vant.Toast('您选择的地址没有解析到结果！');
						}
					}, this.cityName || '北京市')
				},
				selectThisAddress: function () {
					console.log('地图界面点击确认选择经纬度了====')
					var cen = map.getCenter();
					this.longitude = cen.lng.toFixed(6)
					this.latitude = cen.lat.toFixed(6)
					this.longitude_latitude = cen.lng.toFixed(6) + ',' + cen.lat.toFixed(6)
					this.stationAddress = this.station_juti_address
					this.showPopup = false
					// this.baiduInverseGeocoding();
				},
				baiduInverseGeocoding: function () {
					var that = this;
					let Geo = new BMap.Geocoder();
					console.log('逆地理编码====')
					if (isNaN(that.longitude) || isNaN(that.latitude)) {
						return
					}
					let point = new BMap.Point(that.longitude, that.latitude);
					Geo.getLocation(point, rs => {
						console.log(rs)
						var addComp = rs.addressComponents;
						// addComp.province +
						// 	" " +
						// 	addComp.city +
						// 	" " +
						// 	addComp.district +
						// 	" " +
						// 	addComp.street +
						// 	" " +
						// 	addComp.streetNumber
						that.station_area = addComp.province + "/" + addComp.city + "/" + addComp.district;
						that.stationAddress = addComp.street + "" + addComp.streetNumber;
						that.cityName = addComp.province;
						that.station_juti_address = addComp.street + "" + addComp.streetNumber;
						console.log(addComp);
						// 获取省市区 对应的code
						for (var i in area_list.province_list) {
							if (area_list.province_list[i] == rs.addressComponents.province) {
								that.provinceId = i
							}
						}
						for (var i in area_list.city_list) {
							if (area_list.city_list[i] == rs.addressComponents.city) {
								that.cityId = i
							}
						}
						for (var i in area_list.county_list) {
							if (area_list.county_list[i] == rs.addressComponents.district) {
								that.townsId = i
							}
						}
						// 如果是省直辖县
						if ('省直辖县' == rs.addressComponents.city || '' == rs.addressComponents.city) {
							that.cityId = that.townsId
							that.townsId = ''
						}
					})
				},
				onSearch: function () {
					var self = this
					myGeo.getPoint(this.station_juti_address, function (point) {
						if (point) {
							map.centerAndZoom(point, 16);

						} else {
							alert('您选择的地址没有解析到结果！');
						}
					}, this.cityName || '北京市')
				},
				// 创建工单
				createFormSave: function (json_list_data, fn) {
					var self = this
					localStorage.removeItem('longitude_cen_ejy')
					localStorage.removeItem('longitude_cen_ejy_dizhi')
					if (replace) {
						this.work_order_id = ''
					}
					var data = {
						order_type_id: this.order_type_id || 1,
						title: this.stationName + '-油站上线',
						content: JSON.stringify(json_list_data),
						remark: '',
						admin_id: this.admin_id,
						work_order_id: this.work_order_id,
						is_exchange: 0
					}
					$.ajax({
						url: '/eapi/v1/activity/work/form_save',
						data: data,

						type: 'post',
						dataType: 'json',
						success: function (res) {
							console.log(res)
							if (res.status == 200) {
								var resData = res.data
								self.work_order_id = resData.work_order_id
								localStorage.setItem('ejy_work_order_id', self.work_order_id)
								if (replace) {
									var url = ''
									if (replace == 1) {
										url = replaceParamVal(location.href, 'work_order_id', self.work_order_id)
										url = replaceParamVal(url, 'replace', '')
									}
									location.replace(url)
								}
								self.getFormData(function () {
									self.stationName = json_list.stationName || '' //油站名称
									self.cityName = json_list.cityName || ''
									self.provinceId = json_list.provinceId //省市县，对应地址选择栏
									self.longitude = json_list.longitude
									self.latitude = json_list.latitude

									self.cityId = json_list.cityId
									self.townsId = json_list.townsId
									self.station_area = json_list.station_area
									self.stationAddress = json_list.stationAddress //详细地址
									self.organizationName = json_list.organizationName || ''
									self.area_value = json_list.area_value || ''
									self.longitude = json_list.longitude || ''
									self.latitude = json_list.latitude || ''
									self.getStationType(function () {
										if (json_list.organization) {
											self.organization_name = self.organizations.find(function (element) {
												return element.organizationId == json_list.organization
											}).text
										}
									})
								})
								if (fn) {
									fn()
								}
							}
						}
					})
				},

				getFormData: function (fn) {
					var self = this
					var data = {
						admin_id:self.admin_id,
						work_order_id: this.work_order_id
					}
					$.ajax({
						url: '/eapi/v1/activity/work/info',
						data: data,

						type: 'get',
						dataType: 'json',
						success: function (res) {
							console.log(res)
							if (res.status == 200) {
								var resData = res.data
								json_list = JSON.parse(resData.content)
								if (fn) {
									fn()
								}
							}
						}
					})

				},
				judgeStationName: function (fn) {
					var self = this
					$.ajax({
						// url: '/eapi/v1/activity/work/get_station_info?station_name='+this.stationName,
						url: '/eapi/v1/activity/work/get_sign_station?station_name=' + this.stationName,
						// type: 'get',
						//  dataType: 'json',
						type: 'POST',
						contentType: 'application/json; charset=utf-8',
						data: JSON.stringify({
							station_name: this.stationName
						}),
						success: function (res) {
							console.log(res)
							if (res.status == 200) {
								const data = res.data
								if (data.list.length === 0) {
									vant.Toast('油站暂未签约，请先签约')
									return
								}
								const filterArr = data.list.filter(item => item.station_name === this.stationName)
								if (filterArr.length !== 0) {
									vant.Toast('油站名已被占用，请重新填写')
									return
								}
								if (fn) {
									fn()
								}
							} else {

							}
						},
						error: function (res) {
							var errorJSON = JSON.parse(res.responseText)
							console.log(errorJSON)
							if (errorJSON.error.code == 50001) {
								vant.Toast('油站名已被占用，请重新填写')
							}
						}
					})

				},
				saveGongdan: function () {
					var self = this
					if (!this.stationName) {
						vant.Toast('请输入油站名称');
						return
					}
					if (!this.stationAddress) {
						vant.Toast('请输入详细地址')
						return
					}
					if (!this.longitude_latitude) {
						vant.Toast('请选择经纬度');
						return
					}
					this.judgeStationName(function () {
						if (replace) {
							json_list.stationName = self.stationName

							json_list.station_area = self.station_area
							json_list.latitude = self.latitude
							json_list.longitude = self.longitude
							json_list.cityName = self.cityName
							json_list.provinceId = self.provinceId //省市县，对应地址选择栏
							json_list.cityId = self.cityId
							json_list.townsId = self.townsId
							json_list.stationAddress = self.stationAddress //详细地址
							json_list.area_value = self.area_value
							json_list.longitude_latitude = self.longitude_latitude
							json_list.contractPic = self.contractPicList.contractPic
							json_list.contractPics = self.contractPics
						} else {
							json_list = {
								wordOrderId: self.work_order_id,
								userId: self.admin_id,
								//油品信息
								"stationName": self.stationName, //油站名称
								station_area: self.station_area,
								latitude: self.latitude,
								longitude: self.longitude,
								cityName: self.cityName,
								"provinceId": self.provinceId, //省市县，对应地址选择栏
								"cityId": self.cityId,
								"townsId": self.townsId,
								"stationAddress": self.stationAddress, //详细地址
								area_value: self.area_value,
								longitude_latitude: self.longitude_latitude,
								contractPic:self.contractPicList.contractPic,
								contractPics:self.contractPics
							}
						}

						console.log(json_list);
						self.createFormSave(json_list)
					})

				},

				onConfirm(values) {
					this.showPicker = false
				},
				showArea: function () {
					console.log('显示全部省市区====')
					console.log(area_list);
					if (this.look_gd) {
						return
					}
					this.show_area = true
				},
				comfirmArea: function (res) {
					console.log('地址选择点击确认=====')
					console.log(res)
					var station_area = ''
					for (let area = 0; area < res.length; area++) {
						if (area < res.length - 1) {
							station_area += res[area].name + '/'
						} else {
							station_area += res[area].name
						}
					}
					this.cityName = res[0].name
					this.station_area = station_area
					this.provinceId = res[0].code
					//TODO 问题出现在这里
					if (res[1].name === '省直辖县')  {
						this.cityId = res[2].code
						this.townsId = ''
					} else if (res[1].name === '县') {
						this.cityId = res[0].code
						this.townsId = res[2].code
					} else {
						this.cityId = res[1].code
						this.townsId = res[2].code
					}
					this.show_area = false

				},
				showOrganizationPicker: function () {
					if (this.look_gd) {
						return
					}
					this.show_organization_picker = true
				},
				organizationComfirm: function (res) {
					this.organization_name = res.text
					this.organization = res.organizationId
					this.show_organization_picker = false
				},
				showLevelPicker: function () {
					if (this.look_gd) {
						return
					}
					this.show_level_picker = true
				},
				stationLevelComfirm: function (res) {
					this.stationLevel = res.stationLevel
					this.stationLevelName = res.text
					this.show_level_picker = false
				},
				showPositionPicker: function () {
					if (this.look_gd) {
						return
					}
					this.show_position_picker = true
				},
				stationPositionComfirm: function (val) {
					this.positionName = val.text
					this.positionId = val.positionId
					this.show_position_picker = false
				},
				// 本地缓存数据1分钟一次
				saveJSONLocal: function () {

					if (json_list) {
						json_list.wordOrderId = this.work_order_id
						json_list.userId = this.admin_id
						//油品信息
						json_list.stationName = this.stationName //油站名称
						json_list.cityName = this.cityName
						json_list.provinceId = this.provinceId //省市县，对应地址选择栏
						json_list.cityId = this.cityId
						json_list.townsId = this.townsId
						json_list.stationAddress = this.stationAddress //详细地址
						json_list.longitude_latitude = this.longitude_latitude
						json_list.area_value = this.area_value
						json_list.longitude = this.longitude
						json_list.latitude = this.latitude
						json_list.organization = this.organization //油站类型
						json_list.organizationName = this.organizationName
						json_list.scale = this.scale //油站规模（1单站，2集团站）
						json_list.organizationName = this.organizationName //集团名称
						json_list.stationLevel = this.stationLevel //油站P级
						json_list.stationLevelName = this.stationLevelName
						json_list.telephone = this.telephone //柜台电话
						json_list.managerName = this.managerName //管理人姓名
						json_list.positionId = this.positionId //职务
						json_list.positionName = this.positionName
						json_list.email = this.email
						json_list.station_area = this.station_area
						json_list.station_race_infomation = this.station_race_infomation
						json_list.phone = this.phone //管理人
					} else {
						json_list = {
							wordOrderId: this.work_order_id,
							userId: this.admin_id,
							//油品信息
							"stationName": this.stationName, //油站名称
							cityName: this.cityName,
							"provinceId": this.provinceId, //省市县，对应地址选择栏
							"cityId": this.cityId,
							"townsId": this.townsId,
							"stationAddress": this.stationAddress, //详细地址
							area_value: this.area_value,
							longitude: this.longitude,
							latitude: this.latitude,
							longitude_latitude: this.longitude_latitude,
							"organization": this.organization, //油站类型
							"scale": this.scale, //油站规模（1单站，2集团站）
							"organizationName": this.organizationName, //集团名称
							"stationLevel": this.stationLevel, //油站P级
							stationLevelName: this.stationLevelName,
							"telephone": this.telephone, //柜台电话
							"managerName": this.managerName, //管理人姓名
							"positionId": this.positionId, //职务
							positionName: this.positionName,
							"email": this.email,
							station_area: this.station_area,
							station_race_infomation: this.station_race_infomation,
							"phone": this.phone //管理人
						}
					}
					localStorage.setItem('ejy_json_list', JSON.stringify(json_list))
				},
				comeToExtraMsg: function () {
					var self = this
					location.replace('extra_message.html?look_gd_text=' + this.look_gd_text + '&look_gd=' + this.look_gd + '&work_order_id=' + self.work_order_id + '&admin_id=' + self.admin_id + '&order_type_id=' + self.order_type_id + '&reback_url=' + encodeURIComponent(location.href))
				},
				onSubmit: function (values) {
					var self = this
					json_list.wordOrderId = this.work_order_id
					json_list.userId = this.admin_id
					json_list.stationName = this.stationName, //油站名称
						json_list.station_area = this.station_area,
						json_list.latitude = this.latitude,
						json_list.longitude = this.longitude,
						json_list.cityName = this.cityName,
						json_list.provinceId = this.provinceId, //省市县，对应地址选择栏
						json_list.cityId = this.cityId,
						json_list.townsId = this.townsId,
						json_list.stationAddress = this.stationAddress, //详细地址
						json_list.area_value = this.area_value,
						json_list.longitude_latitude = this.longitude_latitude,
						json_list.organization = this.organization //油站类型
					json_list.scale = this.scale //油站规模（1单站，2集团站）
					json_list.organizationName = this.organizationName  //集团名称
					json_list.organization_name = this.organization_name,
						json_list.longitude_latitude = this.longitude_latitude,
						json_list.stationAddress = this.stationAddress,
						json_list.longitude = this.longitude
					json_list.latitude = this.latitude
					json_list.stationLevel = this.stationLevel //油站P级
					json_list.telephone = this.telephone//柜台电话
					json_list.managerName = this.managerName //管理人姓名
					json_list.positionId = this.positionId //职务
					json_list.positionName = this.positionName
					json_list.email = this.email
					json_list.station_race_infomation = this.station_race_infomation
					json_list.phone = this.phone //管理人
					this.createFormSave(json_list, function () {
						if (getQueryVariable('work_order_id')) {
							location.replace('sencond_index.html?look_gd_text=' + this.look_gd_text + '&work_order_id=' + self.work_order_id + '&from_page=' + self.from_page + '&admin_id=' + self.admin_id + '&order_type_id=' + self.order_type_id + '&reback_url=' + encodeURIComponent(location.href))
						} else {
							location.replace('sencond_index.html?look_gd_text=' + this.look_gd_text + '&work_order_id=' + self.work_order_id + '&from_page=' + self.from_page + '&admin_id=' + self.admin_id + '&order_type_id=' + self.order_type_id + '&reback_url=' + encodeURIComponent(location.href + '&work_order_id=' + self.work_order_id))
						}
					})

				},
				lookNextStep: function () {
					var self = this
					location.replace('sencond_index.html?look_gd_text=' + this.look_gd_text + '&work_order_id=' + self.work_order_id + '&from_page=' + self.from_page + '&admin_id=' + self.admin_id + '&look_gd=' + look_gd + '&reback_url=' + encodeURIComponent(location.href))
				},

				// 获取定位
				getLocation: function (fn) {
					var that = this;

					window.HOST_TYPE = "2";
					window.BMap_loadScriptTime = (new Date).getTime();
					var hm = document.createElement("script");
					hm.src = "//api.map.baidu.com/getscript?v=2.0&ak=uUZas4GaaI6QalSTn8giR2rX&services=&t=" + new Date().getTime();
					hm.onload = function () {
						var geolocation = new BMap.Geolocation();

						var geoc = new BMap.Geocoder();
						geolocation.getCurrentPosition(function (res) {
							// $('.loading').css('display', 'block')
							if (res.latitude && res.longitude) {
								var gpsPoint = new BMap.Point(res.longitude, res.latitude); // 创建点坐标 
								that.latitude = res.latitude
								that.longitude = res.longitude
								geoc.getLocation(gpsPoint, function (rs) {
									that.address_detail = rs.address
									for (var i in area_list.province_list) {
										if (area_list.province_list[i] == rs.addressComponents.province) {
											that.provinceId = i
										}
									}
									for (var i in area_list.city_list) {
										if (area_list.city_list[i] == rs.addressComponents.city) {
											that.cityId = i
										}
									}
									for (var i in area_list.county_list) {
										if (area_list.county_list[i] == rs.addressComponents.district) {
											that.townsId = i
											that.area_value = i
										}
									}
									// 如果是省直辖县
									if ('省直辖县' === rs.addressComponents.city) {
										that.cityId = that.townsId
										that.townsId = ''
									}
									if ('县' === rs.addressComponents.city) {
										that.cityId = that.provinceId
									}
									console.log(that.area_value)
									console.log(rs)
									console.log('that.cityId' + that.cityId)
									that.cityName = rs.addressComponents.city
									that.station_area = rs.addressComponents.province + '/' + rs.addressComponents.city + '/' + rs.addressComponents
										.district
									that.stationAddress = rs.addressComponents.street + rs.addressComponents.streetNumber
									fn()
								});
							} else {

								city = ''

								vant.Toast("定位失败，请检查定位是否正常打开，再重试~")
							}
						}, function (a) {
							if (look_gd) {

							} else {
								that.showNotPosition = true
							}

						}, {
							enableHighAccuracy: true
						})
					}
					fn()
					var s = document.getElementsByTagName("script")[0];
					s.parentNode.insertBefore(hm, s);

				},
				// 获取油站类型
				getStationType: function (fn) {
					var self = this
					self.organizations = [
						{ organizationId: 1, text: "民营" },
						{ organizationId: 2, text: "中石油" },
						{ organizationId: 3, text: "中石化" },

						{ organizationId: 6, text: "加德士" },
						{ organizationId: 7, text: "中国海油" },
						{ organizationId: 8, text: "中油BP" },
						{ organizationId: 9, text: "其他" }
					]
					if (fn) {
						fn()
					}

				},
				showStation: function () {
					this.show = true
				},
				getStation: function () { //油站列表
					var that = this
					$.ajax({
						type: 'POST',
						url: '/eapi/v1/activity/work/get_sign_station',
						data: {
							station_name: that.stationValue
						},
						success: function (res) {
							if (res.status == 200) {
								that.stationList = res.data.list
								console.log('----------' + res.data.list)
							}
						},
						error: function (res) {

						}
					})
				},
				searchiInput: function () { //模糊搜索
					this.getStation()
				},
				getFormData2: function(fn) {
						var self = this
						if(getQueryVariable('sign_id')){
							var data = {
								admin_id: self.admin_id,
								work_order_id: getQueryVariable('sign_id')
							}
						}else{
							var data = {
								admin_id:self.admin_id,
								work_order_id: self.work_order_id_sign
							}
						}
						$.ajax({
							url: '/eapi/v1/activity/work/info',
							data: data,
							type: 'get',
							 dataType: 'json',
							success: function(res) {
								if(res.status == 200) {
									self.contractPicList = JSON.parse(res.data.content)
									self.contractPics = [
										{ 
											
											content: self.contractPicList.contractPic,
											file: '',
											isImage: true,
											message: "",
											status: ""
										}
									]
									console.log(self.contractPics)
								}
							}
						})
						
					},
				searchClick: function (item) {
					this.show = false;
					this.station_id = item.id
					this.stationName = item.station_name
					this.work_order_id_sign = item.work_order_id
					this.getStationsWorkOrder()
					this.getFormData2()
				},
			}
		});
		Vue.use(vant.Lazyload);
	</script>
</body>

</html>